package com.asis.ra.demo;



import com.metaio.Template.R;
import com.metaio.sdk.MetaioDebug;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

@SuppressLint("SetJavaScriptEnabled")
public class GuiListObjetos extends Activity {
private WebView webView;
boolean mLaunchingTutorial;
View mProgress;
@Override
	protected void onCreate(Bundle savedInstanceState) {
	    //	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		webView = (WebView) findViewById(R.id.webView1);		
		WebSettings settings = webView.getSettings();
		settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
		settings.setJavaScriptEnabled(true);
		webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
		webView.setWebViewClient(new WebViewHandler());
		Bundle extras = getIntent().getExtras();
		String idindex = extras.getString("index");
		MetaioDebug.log(Log.ERROR, "codigo index : " + idindex);
		if(idindex.equals("01")){
		webView.loadUrl("file:///android_asset/www/files/index.html");}
		if(idindex.equals("02")){
		webView.loadUrl("file:///android_asset/www/files/index2.html");}
		
		// aca se agregan los mas index segun el idindex
		
		webView.setVisibility(View.VISIBLE);
	}
	class WebViewHandler extends WebViewClient
	{
	    @Override
	    public boolean shouldOverrideUrlLoading(WebView view, String url) 
	    {
	    	
	    	 	
	    	final String ImagenId = url.substring(url.lastIndexOf("=") + 1);
	    	
	    	MetaioDebug.log("Tutorial ID detected: "+ImagenId);
	    	
	    	Intent intent = new Intent(getApplicationContext(), ImagenCamera.class);
	    	intent.putExtra("id",ImagenId) ;
	    	
	    	if (url.toLowerCase().startsWith("museo01://"))
	    	{
	    	intent.putExtra("idmuseo","01") ;			
			} 
	    	if (url.toLowerCase().startsWith("museo02://"))
	    	{
	    	intent.putExtra("idmuseo","02") ;			
			} 
	    	if (url.toLowerCase().startsWith("museo03://"))
	    	{
	    	intent.putExtra("idmuseo","03") ;			
			} 
	    	if (url.toLowerCase().startsWith("museo04://"))
	    	{
	    	intent.putExtra("idmuseo","04") ;			
			} 
	    	
	   // aca se agregan los museos 
	  
	    	startActivity(intent);
	    	
	    	
	    	// aca se crea 
	    	
	    	return true;
	    }
	}
}
